<template>
    <div class="noteSet">
        <Row>
            <Col span="24">
                <h2 class="ivu-modal-header">备注设置</h2>
                <div class="mt-10">
                    <Form ref="noteRef" :model="noteForm" :label-width=150  class="conventional-form">
                        <Form-item label="修改订单发票时" class="conventional-form-item">
                            <Radio-group v-model="noteForm.editInvoiceRemark">
                                    <Radio label="true">
                                        <span>必须填写备注</span>
                                    </Radio>
                                    <Radio label="false">
                                        <span>无需填写备注</span>
                                    </Radio>
                            </Radio-group>
                        </Form-item>
                        <Form-item label="修改订单“收货人信息”时" class="conventional-form-item">
                            <Radio-group v-model="noteForm.editOrderReceiverRemark">
                                    <Radio label="true">
                                        <span>必须填写备注</span>
                                    </Radio>
                                    <Radio label="false">
                                        <span>无需填写备注</span>
                                    </Radio>
                            </Radio-group>
                        </Form-item>
                        <Form-item label="修改订单“商品信息”时" class="conventional-form-item">
                            <Radio-group v-model="noteForm.editOrderItemRemark">
                                    <Radio label="true">
                                        <span>必须填写备注</span>
                                    </Radio>
                                    <Radio label="false">
                                        <span>无需填写备注</span>
                                    </Radio>
                            </Radio-group>
                        </Form-item>
                        <Form-item label="修改订单“订单费用”时" class="conventional-form-item">
                            <Radio-group v-model="noteForm.editOrderPriceRemark">
                                    <Radio label="true" >
                                        <span>必须填写备注</span>
                                    </Radio>
                                    <Radio label="false">
                                        <span>无需填写备注</span>
                                    </Radio>
                            </Radio-group>
                        </Form-item>
                        <Form-item label="关闭订单时" class="conventional-form-item">
                            <Radio-group v-model="noteForm.closeOrderRemark">
                                    <Radio label="true">
                                        <span>必须填写备注</span>
                                    </Radio>
                                    <Radio label="false">
                                        <span>无需填写备注</span>
                                    </Radio>
                            </Radio-group>
                        </Form-item>
                        <Form-item label="取消订单时" class="conventional-form-item">
                            <Radio-group v-model="noteForm.cancelOrderRemark">
                                    <Radio label="true">
                                        <span>必须填写备注</span>
                                    </Radio>
                                    <Radio label="false">
                                        <span>无需填写备注</span>
                                    </Radio>
                            </Radio-group>
                        </Form-item>
                        <Form-item label="退货处理时" class="conventional-form-item">
                            <Radio-group v-model="noteForm.refundItemRemark">
                                    <Radio label="true">
                                        <span>必须填写备注</span>
                                    </Radio>
                                    <Radio label="false" >
                                        <span>无需填写备注</span>
                                    </Radio>
                            </Radio-group>
                        </Form-item>
                        <Form-item label="退货确认收货时" class="conventional-form-item">
                            <Radio-group  v-model="noteForm.returnConfirmation">
                                    <Radio label="true">
                                        <span>必须填写备注</span>
                                    </Radio>
                                    <Radio label="false">
                                        <span>无需填写备注</span>
                                    </Radio>
                            </Radio-group>
                        </Form-item>
                        <Form-item label="退款处理时" class="conventional-form-item">
                            <Radio-group v-model="noteForm.refundReceiveConfirmRemark">
                                    <Radio label="true">
                                        <span>必须填写备注</span>
                                    </Radio>
                                    <Radio label="false">
                                        <span>无需填写备注</span>
                                    </Radio>
                            </Radio-group>
                        </Form-item>
                        <Form-item label="修改积分或成长值时" class="conventional-form-item">
                            <Radio-group v-model="noteForm.editPointsRemark">
                                    <Radio label="true">
                                        <span>必须填写备注</span>
                                    </Radio>
                                    <Radio label="false">
                                        <span>无需填写备注</span>
                                    </Radio>
                            </Radio-group>
                        </Form-item>
                    </Form>
                </div>
            </Col>
            <Col span="24" class="ta-c">
                <Button type="primary" @click.native="submitBasic('noteRef')">提交</Button>
                <Button @click.native="closeBasic">取消</Button>
            </Col>
        </Row>
        <Spin size="large" fix v-show="showSpin">
            请稍后....
        </Spin> 
    </div>
</template>
<script>
export default {
    name: 'noteSet',
    props: ['shopIds'],
    data () {
        return {
            showSpin: false,
            shopId: '',
            disabledMdifyInvoice: true,
            noteForm: {
                editInvoiceRemark: 'true', // 修改订单发票时
                editOrderReceiverRemark: 'true', // 修改订单“收货人信息”时
                editOrderItemRemark: 'true', // 修改订单“商品信息”时
                editOrderPriceRemark: 'true', // 修改订单“费用信息”时
                closeOrderRemark: 'true', // 关闭订单时
                cancelOrderRemark: 'true', // 取消订单时Cancel
                refundItemRemark: 'true', // 退货处理
                returnConfirmation: 'true', // 退货确认
                refundReceiveConfirmRemark: 'true', // 退款处理时
                editPointsRemark: 'true' // 修改积分或成长值时
            }
        };
    },
    mounted () {
        this.shopId = this.$route.query.id;
        this.findShop();
    },
    methods: {
        findShop () {
            depot.get({
                url: this.URL.EC_SELLER.SHOP_FIND_ID + '?id=' + this.shopId,
                cb: (data) => {
                    if (data.code === 0) {
                        this.noteForm = data.data;
                        if (this.noteForm.editInvoiceRemark == true) {
                            this.noteForm.editInvoiceRemark = 'true';
                        } else {
                            this.noteForm.editInvoiceRemark = 'false';
                        };
                        if (this.noteForm.editOrderReceiverRemark == true) {
                            this.noteForm.editOrderReceiverRemark = 'true';
                        } else {
                            this.noteForm.editOrderReceiverRemark = 'false';
                        };

                        if (this.noteForm.editOrderItemRemark == true) {
                            this.noteForm.editOrderItemRemark = 'true';
                        } else {
                            this.noteForm.editOrderItemRemark = 'false';
                        };

                        if (this.noteForm.editOrderPriceRemark == true) {
                            this.noteForm.editOrderPriceRemark = 'true';
                        } else {
                            this.noteForm.editOrderPriceRemark = 'false';
                        };

                        if (this.noteForm.closeOrderRemark == true) {
                            this.noteForm.closeOrderRemark = 'true';
                        } else {
                            this.noteForm.closeOrderRemark = 'false';
                        };

                        if (this.noteForm.cancelOrderRemark == true) {
                            this.noteForm.cancelOrderRemark = 'true';
                        } else {
                            this.noteForm.cancelOrderRemark = 'false';
                        };

                        if (this.noteForm.refundItemRemark == true) {
                            this.noteForm.refundItemRemark = 'true';
                        } else {
                            this.noteForm.refundItemRemark = 'false';
                        };

                        if (this.noteForm.returnConfirmation == true) {
                            this.noteForm.returnConfirmation = 'true';
                        } else {
                            this.noteForm.returnConfirmation = 'false';
                        };

                        if (this.noteForm.refundReceiveConfirmRemark == true) {
                            this.noteForm.refundReceiveConfirmRemark = 'true';
                        } else {
                            this.noteForm.refundReceiveConfirmRemark = 'false';
                        };

                        if (this.noteForm.editPointsRemark == true) {
                            this.noteForm.editPointsRemark = 'true';
                        } else {
                            this.noteForm.editPointsRemark = 'false';
                        };
                    }
                },
                ce: (error) => {
                    this.$Message.error(data.message);
                }
            });
        },
        // 提交商城基础设置
        submitBasic (name) {
            this.showSpin = true;
            // 常规设置
            let vue = this;
            vue.noteForm.shopId = this.shopId;
            vue.showSpin = true;
            // alert(1233)
            depot.post({
                url: vue.URL.EC_SELLER.UPDATE_SHOP_SETTINGS,
                data: vue.noteForm,
                cb: (data) => {
                    // this.showSpin = false;
                    if (data.code === 0) {
                        this.$Message.success('提交成功');
                        this.showSpin = false;
                        // this.findShop();
                    }else {
                        // this.$Message.error(data.message);
                        this.showSpin = false;
                    }
                }
            });
        },
        // 取消提交商城基础设置
        closeBasic () {

        }
    },
    watch: {
        shopIds (newVal, oldVal) {
            if (newVal) {
                this.shopId = newVal;
                this.findShop();
            }
            console.log(this.shopId, 'ppp');
        }
    }
};
</script>
<style lang="less" scoped>
    .noteSet{
        
    }
</style>


